class Solution {
public:
    ListNode* getKthFromEnd(ListNode* head, int k) 
    {
        ListNode* p = head;
        ListNode* q = head;

        for(int i = 0; i < k; i++)
        {
            p = p -> next;
        }

        while(p)
        {
            p = p -> next;
            q = q -> next;
        }
        return q;
    }
};